<?php

namespace app\model;

//use support\Model;
use support\Db;
use Illuminate\Database\Eloquent\Model;

class WaSupplierInsuranceCompanyRelevance
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_supplier_insurance_company_relevance';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    public static function all($condition)
    {
        $list = Db::table('wa_supplier_insurance_company_relevance')
            ->select('*')
            ->where($condition)
            ->get();
        if ($list){
            foreach ($list as $k){
//                $k->option_package = json_decode($k->option_package);
//                // car_type  1 轿车 2 SUV 3 MPV 4 跑车 5 新能源
//                if ($k->car_type == 1){
//                    $k->car_type_name = '轿车';
//                }elseif($k->car_type == 2){
//                    $k->car_type_name = 'SUV';
//                }elseif($k->car_type == 3){
//                    $k->car_type_name = 'MPV';
//                }elseif($k->car_type == 4){
//                    $k->car_type_name = '跑车';
//                }elseif($k->car_type == 5){
//                    $k->car_type_name = '新能源';
//                }else{
//                    $k->car_type_name = '';
//                }


            }
        }

        return json_encode($list);
    }


    public static function created($data){
        $result = Db::table('wa_supplier_insurance_company_relevance')->insertGetId($data);
        return $result;
    }

    public static function updated($data,$where){
        $result = Db::table('wa_supplier_insurance_company_relevance')->where($where)->update($data);
        return $result;
    }

    public static function geted($where){
        $result = Db::table('wa_supplier_insurance_company_relevance')->where($where)
            ->get();
        return json_decode($result);
    }

    public static function delete($where){
        $result = Db::table('wa_supplier_insurance_company_relevance')->where($where)->delete();
        return $result;
    }

    public static function sums($where){
        $result = Db::table('wa_supplier_insurance_company_relevance')->where($where)->sum('');
        return $result;
    }

    public static function counts($where){
        $result = Db::table('wa_supplier_insurance_company_relevance')->where($where)->sum('');
        return $result;
    }


}